﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PL.Formularios
{
    public partial class frmReportes : Form
    {
        int _numReporte, _FolioVenta;

        public frmReportes(int numReporte)
        {
            InitializeComponent();
            _numReporte = numReporte;
        }

        public frmReportes(int numReporte, int FolioVenta)
        {
            InitializeComponent();
            _numReporte = numReporte;
            _FolioVenta = FolioVenta;
        }

        private void frmReportes_Load(object sender, EventArgs e)
        {
            try
            {
                Microsoft.Reporting.WinForms.ReportDataSource reportDataSource1 = new Microsoft.Reporting.WinForms.ReportDataSource();

                switch (_numReporte)
                {
                    case 1:
                        {
                            this.ventasTableAdapter.FillByComercial(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentasResumen";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte general de ventas de producto comercial"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentasResumen.rdlc";                            
                        } break;
                    case 2: 
                        {
                            this.ventasTableAdapter.FillBySemilla(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentasResumen";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo","Reporte general de ventas de producto semilla"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentasResumen.rdlc";
                        } break;
                    case 3:
                        {
                            this.ventasTableAdapter.FillByFolioVenta(this.dsAgriComer.ventas, _FolioVenta);
                            reportDataSource1.Name = "dsVentaCaratula";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de venta"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVenta.rdlc";
                        } break;
                    case 4:
                        {
                            this.ventasTableAdapter.FillByPagados(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentas";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de ventas pagadas"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentas.rdlc";
                        } break;
                    case 5:
                        {
                            this.ventasTableAdapter.FillBySinPreliquidar(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentas";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de ventas Sin Preliquidar"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentas.rdlc";
                        } break;
                    case 6:
                        {
                            this.ventasTableAdapter.FillByPreliquidados(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentas";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de ventas Preliquidadas"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentas.rdlc";
                        } break;
                    case 7:
                        {
                            this.ventasTableAdapter.FillBySociedad(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentas";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de ventas en Sociedad"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentas.rdlc";
                        } break;
                    case 8:
                        {
                            this.ventasTableAdapter.FillByBodega(this.dsAgriComer.ventas);
                            reportDataSource1.Name = "dsVentas";
                            reportDataSource1.Value = this.ventasBindingSource;
                            this.reportViewer1.LocalReport.DataSources.Add(reportDataSource1);
                            this.reportViewer1.LocalReport.SetParameters(new Microsoft.Reporting.WinForms.ReportParameter("titulo", "Reporte de ventas Bodega"));
                            this.reportViewer1.LocalReport.ReportEmbeddedResource = "PL.Reportes.rptVentas.rdlc";
                        } break;
                    default: break;
                }
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
    }
}
